home *** CD-ROM | disk | FTP | other *** search
/ Aminet 48 / Aminet 48 (2002)(GTI - Schatztruhe)[!][Apr 2002].iso / Aminet / text / edit / vim60rt.lha / Vim / vim60 / doc / usr_11.txt < prev    next >
Encoding:
Text File  |  2001-09-26  |  10.2 KB  |  255 lines

  1. *usr_11.txt*    For Vim version 6.0.  Last change: 2001 Sep 03
  2.  
  3.              VIM USER MANUAL - by Bram Moolenaar
  4.  
  5.                Recovering from a crash
  6.  
  7.  
  8. Did your computer crash?  And you just spent hours editing?  Don't panic!  Vim
  9. keeps enough information on harddisk to be able to restore most of your work.
  10. This chapter shows you how to get your work back and explains how the swap
  11. file is used.
  12.  
  13. |11.1|    Basic recovery
  14. |11.2|    Where is the swap file?
  15. |11.3|    Crashed or not?
  16. |11.4|    Further reading
  17.  
  18.      Next chapter: |usr_12.txt|  Clever tricks
  19.  Previous chapter: |usr_10.txt|  Making big changes
  20. Table of contents: |usr_toc.txt|
  21.  
  22. ==============================================================================
  23. *11.1*    Basic recovery
  24.  
  25. In most cases recovering a file is quite simple, assuming you know which file
  26. you were editing (and the harddisk is still working).  Start Vim on the file,
  27. with the "-r" argument added: >
  28.  
  29.     vim -r help.txt
  30.  
  31. Vim will read the swap file (used to store text you were editing) and may read
  32. bits and pieces of the original file.  If all is well, you will see these
  33. messages (with different file names, of course):
  34.  
  35.     Using swap file ".help.txt.swp" ~
  36.     Original file "~/vim/runtime/doc/help.txt" ~
  37.     Recovery completed. You should check if everything is OK. ~
  38.     (You might want to write out this file under another name ~
  39.     and run diff with the original file to check for changes) ~
  40.     Delete the .swp file afterwards. ~
  41.  
  42. To be on the safe side, write this file under another name: >
  43.  
  44.     :write help.txt.recovered
  45.  
  46. Compare the file with the original file to check if you ended up with what you
  47. expected.  Vimdiff is very useful for this |08.7|.  Watch out for the original
  48. file to contain a more recent version (you saved the file just before the
  49. computer crashed).  And check that no lines are missing (something went wrong
  50. that Vim could not recover).
  51.    If Vim produces warning messages when recovering, read them carefully.
  52. This is rare though.
  53.  
  54. It's normal that the last few changes can not be recovered.  Vim flushes the
  55. changes to disk when you don't type for about four seconds, or after typing
  56. about two hundred characters.  This is set with the 'updatetime' and
  57. 'updatecount' options.  Thus when Vim didn't get a chance to save itself when
  58. the system went down, the changes after the last flush will be lost.
  59.  
  60. If you were editing without a file name, give an empty string as argument: >
  61.  
  62.     vim -r ""
  63.  
  64. You must be in the right directory, otherwise Vim can't find the swap file.
  65.  
  66. ==============================================================================
  67. *11.2*    Where is the swap file?
  68.  
  69. Vim can store the swap file in several places.  Normally it is in the same
  70. directory as the original file.  To find it, change to the directory of the
  71. file, and use: >
  72.  
  73.     vim -r
  74.  
  75. Vim will list the swap files that it can find.  It will also look in other
  76. directories where the swap file for files in the current directory may be
  77. located.  It will not find swap files in any other directories though, it
  78. doesn't search the directory tree.
  79.    The output could look like this:
  80.  
  81.     Swap files found: ~
  82.        In current directory: ~
  83.     1.    .main.c.swp ~
  84.           owned by: mool   dated: Tue May 29 21:00:25 2001 ~
  85.          file name: ~mool/vim/vim6/src/main.c ~
  86.           modified: YES ~
  87.          user name: mool   host name: masaka.moolenaar.net ~
  88.         process ID: 12525 ~
  89.        In directory ~/tmp: ~
  90.           -- none -- ~
  91.        In directory /var/tmp: ~
  92.           -- none -- ~
  93.        In directory /tmp: ~
  94.           -- none -- ~
  95.  
  96. If there are several swap files that look like they may be the one you want to
  97. use, a list is given of these swap files and you are requested to enter the
  98. number of the one you want to use.  Carefully look at the dates to decide
  99. which one you want to use.
  100.    In case you don't know which one to use, just try them one by one and check
  101. the resulting files if they are what you expected.
  102.  
  103.  
  104. USING A SPECIFIC SWAP FILE
  105.  
  106. If you know which swap file needs to be used, you can recover by giving the
  107. swap file name.  Vim will then finds out the name of the original file from
  108. the swap file.
  109.  
  110. Example: >
  111.     Vim -r .help.txt.swo
  112.  
  113. This is also handy when the swap file is in another directory than expected.
  114. If this still does not work, see what file names Vim reports and rename the
  115. files accordingly.  Check the 'directory' option to see where Vim may have
  116. put the swap file.
  117.  
  118.     Note:
  119.     Vim tries to find the swap file by searching the directories in the
  120.     'dir' option, looking for files that match "filename.sw?".  If
  121.     wildcard expansion doesn't work (e.g., when the 'shell' option is
  122.     invalid), Vim does a desperate try to find the file "filename.swp".
  123.     If that fails too, you will have to give the name of the swapfile
  124.     itself to be able to recover the file.
  125.  
  126. ==============================================================================
  127. *11.3*    Crashed or not?                    *ATTENTION* *E325*
  128.  
  129. Vim tries to protect you from doing stupid things.  Suppose you innocently
  130. start editing a file, expecting the contents of the file to show up.  Instead,
  131. Vim produces a very long message:
  132.  
  133.         E325: ATTENTION ~
  134.     Found a swap file by the name ".main.c.swp" ~
  135.           owned by: mool   dated: Tue May 29 21:09:28 2001 ~
  136.          file name: ~mool/vim/vim6/src/main.c ~
  137.           modified: no ~
  138.          user name: mool   host name: masaka.moolenaar.net ~
  139.         process ID: 12559 (still running) ~
  140.     While opening file "main.c" ~
  141.              dated: Tue May 29 19:46:12 2001 ~
  142.  ~
  143.     (1) Another program may be editing the same file. ~
  144.         If this is the case, be careful not to end up with two ~
  145.         different instances of the same file when making changes. ~
  146.         Quit, or continue with caution. ~
  147.  ~
  148.     (2) An edit session for this file crashed. ~
  149.         If this is the case, use ":recover" or "vim -r main.c" ~
  150.         to recover the changes (see ":help recovery"). ~
  151.         If you did this already, delete the swap file ".main.c.swp" ~
  152.         to avoid this message. ~
  153.  
  154. You get this message, because, when starting to edit a file, Vim checks if a
  155. swap file already exists for that file.  If there is one, there must be
  156. something wrong.  It may be one of these two situations.
  157.  
  158. 1. Another edit session is active on this file.  Look in the message for the
  159.    line with "process ID".  It might look like this:
  160.  
  161.         process ID: 12559 (still running) ~
  162.  
  163.    The text "(still running)" indicates that the process editing this file
  164.    runs on the same computer.  When working on a non-Unix system you will not
  165.    get this extra hint.  When editing a file over a network, you may not see
  166.    the hint, because the process might be running on another computer.  In
  167.    those two cases you must find out what the situation is yourself.
  168.       If there is another Vim editing the same file, continuing to edit will
  169.    result in two versions of the same file.  The one that is written last will
  170.    overwrite the other one, resulting in loss of changes.  You better quit
  171.    this Vim.
  172.  
  173. 2. The swap file might be the result from a previous crash of Vim or the
  174.    computer.  Check the dates mentioned in the message.  If the date of the
  175.    swap file is newer than the file you were editing, and this line appears:
  176.  
  177.         modified: YES ~
  178.  
  179.    Then you very likely have a crashed edit session that is worth recovering.
  180.       If the date of the file is newer than the date of the swap file, it was
  181.    probably changed after the crash.  Perhaps you recovered it earlier, but
  182.    didn't delete the swap file?  Vim will warn you for this with this extra
  183.    line:
  184.  
  185.       NEWER than swap file! ~
  186.  
  187.  
  188. WHAT TO DO?
  189.  
  190. If dialogs are supported you will be asked to select one of five choices:
  191.  
  192.   Swap file ".main.c.swp" already exists! ~
  193.   [O]pen Read-Only, (E)dit anyway, (R)ecover, (Q)uit, (D)elete it: ~
  194.  
  195. O  Open the file readonly.  Use this when you just want to view the file and
  196.    don't need to recover it.  You might want to use this when you know someone
  197.    else is editing the file, but you just want to look in it and not make
  198.    changes.
  199.  
  200. E  Edit the file anyway.  Use this with caution!  If the file is being edited
  201.    in another Vim, you might end up with two versions of the file.  Vim will
  202.    try to warn you when this happens, but better be safe then sorry.
  203.  
  204. R  Recover the file from the swap file.  Use this if you know that the swap
  205.    file contains changes that you want to recover.
  206.  
  207. Q  Quit.  This avoids starting to edit the file.  Use this if there is another
  208.    Vim editing the same file.
  209.       When you just started Vim, this will exit Vim.  When starting Vim with
  210.    files in several windows, Vim quits only if there is a swap file for the
  211.    first one.  When using an edit command, the file will not be loaded and you
  212.    are taken back to the previously edited file.
  213.  
  214. D  Delete the swap file.  Use this when you are sure you no longer need it.
  215.    For example, when it doesn't contain changes, or when the file itself is
  216.    newer than the swap file.
  217.       On Unix this choice is only offered when the process that created the
  218.    swap file does not appear to be running.
  219.  
  220. If you do not get the dialog (you are running a version of Vim that does not
  221. support it), you will have to do it manually.  To recover the file, use this
  222. command: >
  223.  
  224.     :recover
  225.  
  226.  
  227. Vim cannot always detect that a swap file already exists for a file.  This is
  228. the case when the other edit session puts the swap files in another directory
  229. or when the path name for the file is different when editing it on different
  230. machines.  Therefore, don't rely on Vim always warning you.
  231.  
  232. If you really don't want to see this message, you can add the 'A' flag to the
  233. 'shortmess' option.  But it's very unusual that you need this.
  234.  
  235. ==============================================================================
  236. *11.4*    Further reading
  237.  
  238. |swap-file|    An explanation about where the swap file will be created and
  239.         what its name is.
  240. |:preserve|    Manually flushing the swap file to disk.
  241. |:swapname|    See the name of the swap file for the current file.
  242. 'updatecount'    Number of key strokes after which the swap file is flushed to
  243.         disk.
  244. 'updatetime'    Timeout after which the swap file is flushed to disk.
  245. 'swapsync'    Whether the disk is synced when the swap file is flushed.
  246. 'directory'    List of directory names where to store the swap file.
  247. 'maxmem'    Limit for memory usage before writing text to the swap file.
  248. 'maxmemtot'    Same, but for all files in total.
  249.  
  250. ==============================================================================
  251.  
  252. Next chapter: |usr_12.txt|  Clever tricks
  253.  
  254. Copyright: see |manual-copyright|  vim:tw=78:ts=8:ft=help:norl:
  255.